<?php
$base_url = '';
if ($lang == 'cn') $base_url = '/chinese';
$pages = array(
    'index' => array('title' => 'Learn', 'url' => $base_url . '/'),
    'test' => array('title' => 'Test', 'url' => $base_url . '/test')
);
$languages = array(
    'en' => array('title' => 'English', 'url' => '/'),
    'cn' => array('title' => 'Chinese', 'url' => '/chinese'),
    'jp' => array('title' => 'Japanese', 'url' => '/japanese')
);
$years = array(
    '2015' => array('title' => '2015', 'url' => '?year=2015'),
    '2014' => array('title' => '2014', 'url' => '?year=2014')
);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Flash Cards <?php echo $version?></title>
    <link href="static/favicon.ico" rel="icon" type="image/x-icon" />
    <!-- Bootstrap -->
    <link href="../bootstrap-3.1.1-dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/style.css" rel="stylesheet">
    <?php
    if ($styles_enqueued != null) {
        foreach ($styles_enqueued as $style_enqueued) {
        ?>
            <link href="<?php echo $style_enqueued['src'];?>" rel="stylesheet">
        <?php
        }
    }
    ?>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="container">
    <h3>Flash Cards <?php echo $version?></h3>
    <div class="row">
        <ul class="breadcrumb">
            <?php
            foreach ($pages as $id => $item) {
                $item_html = '<span class="btn-xs btn-primary">' . $item['title'] . '</span>';
                if ($page != $id) {
                    $item_html = '<a href="' . $item['url'] . '"><span class="btn-xs btn-link btn-primary">' . $item['title'] . '</span></a>';
                }
                if ($item != end($pages)) {
                    $item_html .= '&nbsp;|&nbsp;';
                }
                echo $item_html;
            }
            ?>
            <div class="btn-group pull-right">
                <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
                    <?php echo strtoupper($lang)?> <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    <?php
                        foreach ($languages as $id => $item) {
                            $item_class = '';
                            if ($lang == $id) {
                                $item_class = 'disabled';
                            }
                            echo '<li class="' . $item_class . '"><a href="' . $item['url']. '">' . $item['title'] . '</a></li>';
                        }
                    ?>
                </ul>
            </div>
            <div class="btn-group pull-right">
                <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
                    <?php echo $year;?> <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    <?php
                    foreach ($years as $id => $item) {
                        $item_class = '';
                        if ($year == $id) {
                            $item_class = 'disabled';
                        }
                        echo '<li class="' . $item_class . '"><a href="' . $item['url']. '">' . $item['title'] . '</a></li>';
                    }
                    ?>
                </ul>&nbsp;
            </div>
        </ul>
    </div>
</div>